<?php
namespace Common\Model;
use Common\Model\VRNewsModel;
use Admin\Controller\Tencentyun\Conf;
use Admin\Controller\Tencentyun\ImageV2;
class NewsCommentModel extends VRNewsModel
{
	
	protected $_validate = array(
		//array(验证字段,验证规则,错误提示,验证条件,附加规则,验证时间)
		array('offer_price', 'require', '出价不能为空！', 0, 'regex', CommonModel:: MODEL_BOTH  ),
	);

	/**
	 * 获取评论/回复列表
	 */
	public function getNewsCommentList($formParam = array(), $news_id = null, $pageStart, $pageSize){
		$resultData = array();
		$where = array();
		$where['a.status'] = array('EQ','1');
		if($news_id) $where['a.news_id'] = array('EQ',$news_id);
		if($formParam['keyword']) $where['a.content'] = array('like','%'.$formParam['keyword'].'%');
		if($formParam['startDate']) $where['a.create_time'] =array('egt',$formParam['startDate']);
		if($formParam['endDate']) $where['a.create_time'] = array('elt',$formParam['endDate']);
		
		$count_Total = $this->alias("a")->join("vruser1.user b on a.user_id = b.user_id")->where($where)->count();	
		$news_comment_list = $this
		->alias("a")
		->join("vruser1.user b on a.user_id = b.user_id")
		->where($where)
		->field('a.*,b.nickname')
		->order("a.create_time desc")
		->limit($pageStart, $pageSize)
		->select();
		
		$resultData['data'] = $news_comment_list;
		$resultData['count_Total'] = $count_Total;
		return $resultData;
	}
	
}

